package xyc.szk.api.impl;
/*
 * @Description:
 * @Author: 山志凯
 * @Date: 2021-06-09
 * @Time: 10:06
 */

import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanHandler;
//import sjxy.reflect.ReflectionUtils;
import xyc.szk.api.DbBasic;
import xyc.szk.pojo.Department;
import xyc.szk.pojo.Users;
import xyc.szk.utils.JdbcUtils3;

import java.sql.SQLException;
import java.util.List;

public class DbBasicImpl<T> implements DbBasic<T> {
    private QueryRunner qr=null; //它是线程
    private Class<T> type=null;
    public DbBasicImpl(){
        this.qr=new QueryRunner(JdbcUtils3.getDataSource());
      //  this.type= ReflectionUtils.getSuperGenericType(getClass());//通过反射获取T的类型
    }
    @Override
    public T find(String sql, Object... args) throws SQLException {
        T t=qr.query(sql,new BeanHandler<T>(type),args);
        return t;
    }

    @Override
    public List<T> findAll(String sql, Object... args) {
        return null;
    }

    @Override
    public int update(String sql, Object... args) {
        return 0;
    }
}